/*
 * @Author: 颜礼田 2564217790@qq.com
 * @Date: 2024-09-10 11:05:38
 * @LastEditors: 颜礼田 2564217790@qq.com
 * @LastEditTime: 2024-09-10 11:21:06
 * @FilePath: /webServerAdmin/src/api/modules/area.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import http from "@/api";
import { PORT1 } from "@/api/config/servicePort";
import { AreaSchema } from "@/schema";
import { Id, ReqPage } from "../interface";

export function fetchAreaList(data: ReqPage) {
  return http.post<Array<AreaSchema>>(`${PORT1}/area/list`, data);
}

export function saveArea(data: AreaSchema) {
  return http.post<AreaSchema>(`${PORT1}/area/save`, data);
}

export function fetchAreaTrees() {
  return http.get<{ list: Array<AreaSchema> }>(`${PORT1}/area/trees`);
}

export function fetchByParent(params?: Id) {
  return http.get<Array<AreaSchema>>(`${PORT1}/area/byParentGetChildren`, params);
}

export function fetchAreaInfo(params: Id) {
  return http.get<AreaSchema>(`${PORT1}/area/info`, params);
}

export function removeArea(params: Id) {
  return http.delete<AreaSchema>(`${PORT1}/area/remove`, params);
}

export function editArea(params: Id, data: AreaSchema) {
  return http.put<AreaSchema>(`${PORT1}/area/edit`, data, { params });
}
